﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CJJCH.Web.Manage
{
    public partial class Login : System.Web.UI.Page
    {
        CJJCH.BLL.T_NET_Manager bll_manager = new CJJCH.BLL.T_NET_Manager();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void BuLogin_Click1(object sender, EventArgs e)
        {
            if (Session["ValidateCode"] == null)
            {
                Session["ValidateCode"] = "";
            }
            string UserName = TeUserName.Text;
            if (Session["ValidateCode"].ToString() != TeChecking.Text.Trim())
            {
                LTP.Common.WindowClass.WindowBack("验证码输入错误！");
            }
            else
            {
                string userName = TeUserName.Text.Trim().Replace("'", "");
                string userPass = LTP.Common.StringClass.EncryptPassword(TeUserPwd.Text, LTP.Common.StringClass.PasswordFormat.MD5_32);

                if (userName == "" || userPass == "")
                {
                    LTP.Common.WindowClass.WindowBack("用户名密码不能为空！");
                }
                else
                {
                    CJJCH.Model.T_NET_Manager model = new Model.T_NET_Manager();
                    model = bll_manager.GetListUser(userName);
                    if (model!=null&&userPass == model.UserPwd)
                    {
                        Session["ManagerID"] = model.ID.ToString();
                        Session["RealName"] = model.RealName;
                        Response.Redirect("Default.aspx");
                    }
                    else
                    {
                        model = null;
                        LTP.Common.WindowClass.WindowBack("用户名或密码错误！");
                    }
                }
            }
        }
    }
}